<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use DB;


class MenuOption extends Authenticatable
{
    use Notifiable;
	protected $table = 'admin_menu_option';


    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
         'remember_token',
    ];



	/**
	 *  获取菜单的option_id
	 */
	public static function getMenuOptionId($mid){

		$optionIds = DB::table('admin_menu_option')
			->where('menu_id',$mid)
			->select('option_id')
			->get()
			->toArray();
		if(!$optionIds){
			return array();
		}
		return $optionIds;
	}


	// 获取指定id的name
	public static function getOptionName($op_id){
		$optionName = DB::table('admin_option')
			->where('id',$op_id)
			->select('option_name')
			->get()
			->toArray();
		if(!$optionName){
			return '';
		}
		return $optionName[0]->option_name;
	}


	public static function getOptionId($option_name){
		$optionName = DB::table('admin_option')
			->where('option_name',$option_name)
			->select('id')
			->get()
			->toArray();
		if(!$optionName){
			return 0;
		}
		return $optionName[0]->id;
	}


}
